{extend name="template/base" /}
{block name="content"}
<head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>

    <script type="text/javascript" src="__LIB__/showdown/1.4.2/showdown.min.js"></script>
    <script>window.UEDITOR_HOME_URL = '__LIB__/ueditor/1.4.3/'</script>
    <script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>

    <style type="text/css">

        .select {
            border: 0px;
            outline: 1px solid rgb(204,204,204);
            padding: 5px;
            width: 150px;
            height: 30px;
        }
    </style>

</head>

<div style="margin-top: 60px;">

    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="id" value="{$vo.id ?? ''}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>分类名称：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <div class="formControls col-xs-6 col-sm-6">

                    <select class="select" name = "category">

                        {volist name="groups" id="cat"}

                        <option id="{$cat.name}" value ="{$cat.name}">{$cat.name}</option>

                        {/volist}

                    </select>

                </div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>标题：</label>
            <div class="formControls col-xs-6 col-sm-6">

                <input type="text" class="input-text" placeholder="标题" name="name" value="{$vo.name ?? ''}"  datatype="*" nullmsg="请填写标题">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>状态：</label>

            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                <div class="radio-box">
                    <input type="radio" name="status" id="status-1" value="1">
                    <label for="status-1">启用</label>
                </div>

                <div class="radio-box">
                    <input type="radio" name="status" id="status-0" value="0">
                    <label for="status-0">禁用</label>
                </div>

            </div>

            <div class="col-xs-3 col-sm-3"></div>

        </div>

        <div class="row cl">

            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>内容：</label>

            <div style="margin-top: 20px;">

                <script name = "content" id="editor" type="text/plain" style="height:400px; width:500px;  margin:auto;"></script>

            </div>

        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>

    </form>

</div>

{/block}
{block name="script"}

<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>

    $(function () {

        $("#form").Validform({
            tiptype: 1,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret){

                ajax_progress(ret);

            }
        });
    })

    $("#{$vo.category ?? ''}").prop("selected", true);

    var ue = UE.getEditor('editor',{
        serverUrl:'{:\\think\\Url::build("Ueditor/index")}'
    });

    var htmlContent = '{$vo["content"] ? htmlspecialchars_decode($vo["content"]):""}';

    var status = "{$vo.status ?? ''}";

    if(status == '0'){

        $("#status-0").attr("checked",true);
    }
    else{$("#status-1").attr("checked",true);}

    ue.ready(function() {

        ue.setContent(htmlContent);

    });

</script>
{/block}